import request from '@/utils/request'
import { getToken, setToken } from '@/utils/auth'
// 监控车辆数据列表
export function queryList(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/fence-vehicle-info-page',
    method: 'get',
    params: data
  })
}
// 大区与省市映射数据
export function queryRegions() {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/region-mapper-list',
    method: 'get'
    // params: query
  })
}
// 车系车型关系-下拉框使用
export function queryVehicleMap() {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/vehicle-series-mapper',
    method: 'get'
    // params: query
  })
}
// v1/private/vehicle-series-mapper
// 实时报警数据列表
export function queryHistory(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/alarm-info-page',
    method: 'get',
    params: data
  })
}
// 查询自动下发报警状态
export function queryAlarmSendSwitchStatus(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/alarm-send-switch/status',
    method: 'get',
    params: data
  })
}
// 人工下发报警
export function alarmSend(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/alarm-send',
    method: 'get',
    params: data
  })
}
// 开启/关闭自动下发报警
export function alarmSwitchSend(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/alarm-send-switch',
    method: 'get',
    params: data
  })
}
// 报警记录导出
export function downloadAlarm() {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/img-download/alarm-info-export/**',
    method: 'get'
    // params: query
  })
}
// 处理报警记录
export function handleAlarmRecord(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/alarm-handle',
    method: 'post',
    data
    // params: query
  })
}
/**
 * 电子围栏相关信息
**/
// 查询围栏基础信息表列表
export function queryFenceList(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/fence-info-page',
    method: 'get',
    params: data
  })
}
// 查询所有4S店列表-下拉框使用
export function queryDealerList(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/dealer-list',
    method: 'get',
    params: data
  })
}
// 查询行政区围栏是否已存在
export function queryFenceExist(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/fence-exist',
    method: 'post',
    data
  })
}
// 查询围栏信息详情
export function queryFenceDetail(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/fence-info',
    method: 'get',
    params: data
  })
}
// 添加围栏基础信息表
export function addFence(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/fence-info',
    method: 'post',
    data
  })
}
// 修改围栏信息
export function editFence(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/fence-info',
    method: 'put',
    data
  })
}
// 删除围栏信息
export function deleteFence(ids) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/fence-info/${ids}`,
    method: 'delete'
  })
}
/**
 * 自定义规则相关
 */
// 查询自定义规则表详情
export function customRuleInfo(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/custom-rule-info',
    method: 'get',
    params: data
  })
}
// 添加自定义规则表
export function addCustomRule(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/custom-rule-info',
    method: 'post',
    data
  })
}
// 修改自定义规则表
export function editCustomRule(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/custom-rule-info',
    method: 'put',
    data
  })
}
// 查询自定义规则表列表
export function customRuleList(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/custom-rule-info-page',
    method: 'get',
    params: data
  })
}
export function deleteCustomRule(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/custom-rule-info/${data}`,
    method: 'delete'
  })
}
/**
 * 标准规则接口
 */
// 修改标准规则表
export function editStandardRule(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/standard-rule-info',
    method: 'put',
    data
  })
}
// 标准规则表列表
export function standardRuleList(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/standard-rule-list',
    method: 'get',
    params: data
  })
}
// 开启/关闭规则
export function switchStandardRule(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/standard-rule-switch',
    method: 'put',
    data
  })
}

export function switchFence(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/fence-switch',
    method: 'get',
    params: data
  })
}
//2 导出 (记得引入一下获取token的方法)
export function alarmInfoExport(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/img-download/alarm-info-export/${getToken()}`,
    method: 'get',
    params: data,
    responseType: 'blob'
  })
}
// 报警类型下拉框
export function queryAlarmType() {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/alarm-type`,
    method: 'get'
  })
}
// 查询邮件申诉规则详情
export function handRuleInfo() {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/hand-rule-info',
    method: 'get'
  })
}
// 添加邮件申诉规则
export function addHandRule(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/hand-rule-info',
    method: 'post',
    data
  })
}
/**
 * 白名单相关接口
 */
//  查询城市白名单列表
export function queryWhiteListCity(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-city-info-page',
    method: 'get',
    params
  })
}
export function switchWhiteListCity(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-city-info-switch',
    method: 'get',
    params
  })
}
// 添加城市白名单
export function addWhiteListCity(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-city-info',
    method: 'post',
    data
  })
}
// 修改城市白名单
export function updateWhiteListCity(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-city-info',
    method: 'put',
    data
  })
}
// 根据ID删除城市白名单
export function deleteWhiteListCity(ids) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/whitelist-city-info/${ids}`,
    method: 'delete'
  })
}
export function queryWhiteListCityTrees(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-city-info/box',
    method: 'get',
    params
  })
}
// 查询车型白名单详情
export function detailWhiteListSeries(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-series-info',
    method: 'get',
    params
  })
}
// 添加车型白名单
export function addWhiteListSeries(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-series-info',
    method: 'post',
    data
  })
}

// 查询车辆白名单详情
export function detailWhiteListVehicle(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-vehicle-info',
    method: 'get',
    params
  })
}
// 添加车辆白名单
export function addWhiteListVehicle(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-vehicle-info',
    method: 'post',
    data
  })
}
/**
 * 报警邮件发送管理
 */

// 修改经销商邮箱配置表
export function updateDealerEmail(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/dealer-email-config',
    method: 'put',
    data
  })
}
// 查询经销商邮箱配置表列表
export function queryDealerEmail(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/dealer-email-config-page',
    method: 'get',
    params
  })
}
// 修改经销商邮箱配置状态
export function updateDealerEmailStatus(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/dealer-email-config-status',
    method: 'put',
    data
  })
}
// 导出邮箱数据
export function exportDealerEmail() {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/dealer-email-config/export/${getToken()}`,
    method: 'get',
    responseType: 'blob'
  })
}
// 添加经销商邮箱配置表
export function insertDealerEmail(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/dealer-email-config/insert',
    method: 'post',
    data
  })
}
// 上传经销商邮箱配置表
export function uploadDealerEmail(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/dealer-email-config/upload',
    method: 'post',
    data
  })
}

/**
 * 报备相关接口
 */
// 查询报备详情
export function queryReportInfo(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/report-info',
    method: 'get',
    params
  })
}
export function reportInfoExport(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/img-download/report-info-export',
    method: 'get',
    responseType: 'blob',
    params
  })
}
// 查询报备列表
export function queryReportPage(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/report-info-page',
    method: 'get',
    params
  })
}
// 查询报备品牌车系车型下拉
export function queryReportSelectOptions() {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/report-info/box',
    method: 'get'
  })
}
// 查询报备文件列表
export function queryReportFileInfo(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/report-info/file-info',
    method: 'get',
    params
  })
}
// 查询报备文件流
export function queryReportFiles(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/img-download/report-info-file-stream/${getToken()}`,
    method: 'get',
    responseType: 'blob',
    params
  })
}
// 查询报备审批列表
export function queryReportProcessInfo(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/report-info/process-info',
    method: 'get',
    params
  })
}
/**
 * 申诉相关接口
 */
// 查询申诉详情
export function queryAppealInfo(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/appeal-info',
    method: 'get',
    params
  })
}
export function appealInfoExport(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/img-download/appeal-info-export',
    method: 'get',
    responseType: 'blob',
    params
  })
}
// 查询申诉列表
export function queryAppealPage(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/appeal-info-page',
    method: 'get',
    params
  })
}
// 查询申诉品牌车系车型下拉
export function queryAppealSelectOptions() {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/appeal-info/box',
    method: 'get'
  })
}
// 查询申诉文件列表
export function queryAppealFileInfo(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/appeal-info/file-info',
    method: 'get',
    params
  })
}
// 查询申诉文件流
export function queryAppealFiles(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/img-download/appeal-info-file-stream/${getToken()}`,
    method: 'get',
    responseType: 'blob',
    params
  })
}
// 查询申诉审批列表
export function queryAppealProcessInfo(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/appeal-info/process-info',
    method: 'get',
    params
  })
}
/**
 * 统计分析相关接口
 */
// 关键数据
export function queryCruxData(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/crux-data',
    method: 'get',
    params
  })
}
// 报警类型分布
export function queryAlarmDistribution(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/alarmDistribution',
    method: 'get',
    params
  })
}
// 跨区报警情况排名
export function queryCrossRegional(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/crossRegional',
    method: 'get',
    params
  })
}

// 非属地流入统计
export function queryInflow(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/inflow',
    method: 'get',
    params
  })
}
// 非属地流出统计
export function queryOutflow(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/outflow',
    method: 'get',
    params
  })
}
// 车辆报警情况统计
export function queryVehicleAlarm(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/vehicleAlarm',
    method: 'get',
    params
  })
}
/**
 * 经销店白名单
 * addWhiteListDealer - 添加经销店白名单
 * editWhiteListDealer - 修改经销店白名单
 * queryWhiteListDealer - 查询经销店白名单列表
 * deleteWhiteListDealer - 删除经销店白名单
 * switchWhiteListDealer - 启用/禁用经销店白名单
*/
export function addWhiteListDealer(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-dealer-info',
    method: 'post',
    data
  })
}
export function editWhiteListDealer(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-dealer-info',
    method: 'put',
    data
  })
}
export function queryWhiteListDealer(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-dealer-info-page',
    method: 'get',
    params
  })
}
export function deleteWhiteListDealer(id) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/whitelist-dealer-info/${id}`,
    method: 'delete'
  })
}
export function switchWhiteListDealer(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-dealer-switch',
    method: 'get',
    params
  })
}

/**
 * 车辆白名单
 * addWhiteListSingle - 添加车辆白名单
 * editWhiteListSingle - 修改车辆白名单
 * queryWhiteListSingle - 查询车辆白名单列表
 * deleteWhiteListSingle - 删除车辆白名单
 * switchWhiteListSingle - 启用/禁用车辆白名单
 * exportWhiteListSingle - 导出车辆白名单
 * exportWhiteListSingleTemp - 导出车辆白名单模板
*/
export function addWhiteListSingle(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-single-vehicle-info',
    method: 'post',
    data
  })
}
export function editWhiteListSingle(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-single-vehicle-info',
    method: 'put',
    data
  })
}
export function queryWhiteListSingle(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-single-vehicle-info-page',
    method: 'get',
    params
  })
}
export function deleteWhiteListSingle(id) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/whitelist-single-vehicle-info/${id}`,
    method: 'delete'
  })
}
export function switchWhiteListSingle(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + 'v1/private/whitelist-single-vehicle-switch',
    method: 'get',
    params
  })
}
export function exportWhiteListSingle(params) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/img-download/whitelist-single-export/${getToken()}`,
    method: 'get',
    params,
    responseType: 'blob'
  })
}
export function exportWhiteListSingleTemp() {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/img-download/whitelist-single-temp-export/${getToken()}`,
    method: 'get',
    responseType: 'blob'
  })
}
export function importWhiteListSingle(data) {
  return request({
    url: process.env.SPANNED_MONITOR_SERVICE + `v1/private/whitelist-single-vehicle-import`,
    method: 'post',
    data
  })
}

